home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 5.3 KB | 188 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: EmbedPar.cpp
- // Release Version: $ 1.0d11 $
- //
- // Author: M.Boetcher
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Embed.hpp"
-
- #ifndef EMBEDPART_H
- #include "EmbedPar.h"
- #endif
-
- #ifndef EMBEDDEF_H
- #include "EmbedDef.h"
- #endif
-
- #ifndef EMBEDSEL_H
- #include "EmbedSel.h"
- #endif
-
- #ifndef EMBEDPROXY_H
- #include "EmbedPxy.h"
- #endif
-
- #ifndef EMBEDFRAME_H
- #include "EmbedFra.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfembed
- #endif
-
- //========================================================================================
- // CLASS CEmbedPart
- //========================================================================================
-
- const ODValueType CEmbedPart::kPartKind = kODFEmbedKind;
- const ODValueType CEmbedPart::kPartUserName = kODFEmbedEditorUserString;
-
- #define kMainPresentation "Apple:Presentation:EmbedPart"
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart constructor
- //----------------------------------------------------------------------------------------
-
- CEmbedPart::CEmbedPart(ODPart* odPart):
- FW_CEmbeddingPart(odPart, CEmbedPart::kPartKind, CEmbedPart::kPartUserName, FW_gInstance, kPartIconID),
- fSelection(NULL),
- fPresentation(NULL),
- fProxy(NULL)
- {
- // Do not call anything that can fail
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::Initialize
- //----------------------------------------------------------------------------------------
-
- void CEmbedPart::Initialize(Environment* ev)
- {
- FW_CEmbeddingPart::Initialize(ev);
-
- fSelection = new CEmbedSelection(ev, this); // actually owned by the presentation
- fPresentation = RegisterPresentation(ev, kMainPresentation, TRUE, fSelection);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart destructor
- //----------------------------------------------------------------------------------------
-
- CEmbedPart::~CEmbedPart()
- {
- if (fProxy)
- {
- delete fProxy;
- fProxy = NULL;
- }
-
- // Notice that I don't delete the selection object.
- // It is owned by the presentation object
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::ExternalizeContent
- //----------------------------------------------------------------------------------------
-
- void CEmbedPart::ExternalizeContent(Environment* ev, ODStorageUnit* storageUnit, FW_CCloneInfo* cloneInfo)
- {
- ODValueType contentPropertyValueType = this->GetPartKind(ev);
- storageUnit->Focus(ev, kODPropContents, kODPosUndefined, contentPropertyValueType, 0, kODPosUndefined);
- storageUnit->Remove(ev);
- storageUnit->AddValue(ev, contentPropertyValueType);
-
- // ----- Create an archive -----
- FW_CStorageUnitSink sink(storageUnit, kODPropContents, contentPropertyValueType);
- FW_CWritableStream archive(&sink);
-
- // ----- Write number of embedded parts -----
- unsigned long count = 0;
- if (fProxy)
- count = 1;
- archive << count;
-
- // ----- Write embedded part -----
- if (fProxy)
- fProxy->Externalize(ev, sink.GetStorageUnitView(), cloneInfo);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::InternalizeContent
- //----------------------------------------------------------------------------------------
-
- void CEmbedPart::InternalizeContent(Environment *ev, ODStorageUnit* storageUnit, FW_CCloneInfo* cloneInfo)
- {
- // ----- Create an archive -----
- FW_CStorageUnitSink sink(storageUnit, kODPropContents, this->GetPartKind(ev));
- FW_CReadableStream archive(&sink);
-
- // ----- Read number of embedded parts -----
- unsigned long count;
- archive >> count;
-
- // ----- Read embedded part, if any -----
- if (count == 1)
- {
- fProxy = new CEmbedProxy(ev, this);
- fSelection->SetProxy(ev, fProxy);
- fProxy->Internalize(ev, sink.GetStorageUnitView(), cloneInfo);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::NewFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* CEmbedPart::NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage)
- {
- FW_UNUSED(presentation);
- FW_UNUSED(fromStorage);
-
- return new CEmbedFrame(ev, odFrame, presentation, this);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::SetProxy
- //----------------------------------------------------------------------------------------
-
- void CEmbedPart::SetProxy(Environment* ev, CEmbedProxy* proxy)
- {
- fProxy = proxy;
-
- // a proxy is always selected
- fSelection->SetProxy(ev, proxy);
- }
-
-